package com.gg.cart.contorller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.gg.cart.service.CartService;
import com.gg.entity.User;

import helpers.baseservlet.BaseServlet;
import povos.CartFruitPovo;


@WebServlet("/cart/RemoveCartByCidServlet")
public class RemoveCartByCidServlet extends BaseServlet {
	@Autowired
	private CartService cartService;
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String cid=request.getParameter("cid");
		cartService.removeCartByCid(cid);
		User user=(User) request.getSession().getAttribute("user");
		List<CartFruitPovo> povos=cartService.getCartFruitPovoByUid(user.getUid());
		request.getSession().setAttribute("cartpovos", povos);
		response.sendRedirect("/fruits/showcart.jsp");
	}

	
}
